﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Admin_Plugins.aspx.cs" Inherits="Xiaov.SmartWeb.Application.SysAdmin.Admin_Plugins" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script>
        $(function () {
            $('#tt').datagrid({
                onDblClickRow: function (index, field, value) {
                    var row = $('#tt').datagrid('getSelected');
                    if (confirm('确定要安装' + row.Name + '吗？')) {
                        install(row.FilePath);
                    }
                }
            });

            $('#tt2').datagrid({
                onDblClickRow: function (index, field, value) {
                    var row = $('#tt2').datagrid('getSelected');
                    if (confirm('确定要卸载' + unescape(row.PLUGINNAME) + '吗？')) {
                        uninstall(row.PLUGINID);
                    }                    
                }
            });
        });
        var toolbar = [{
            text: '安装',
            iconCls: 'icon-add',
            handler: function () {
                var row = $('#tt').datagrid('getSelected');
                if (row) {
                    if (confirm('确定要安装' + row.Name + '吗？')) {
                        install(row.FilePath);
                    }
                }
                else {
                    alert('请选中一个插件、或双击进行安装');
                }
            }
        }]

        var toolbar2 = [{
            text: '卸载',
            iconCls: 'icon-remove',
            handler: function () {
                var row = $('#tt2').datagrid('getSelected');
                if (row) {
                    if (confirm('确定要卸载' + unescape(row.PLUGINNAME) + '吗？')) {
                        uninstall(row.PLUGINID);
                    }
                }
                else {
                    alert('请选中一个插件、或双击进行卸载');
                }
            }
        }]

        function callback(res) {            
            $('#tt').datagrid('reload');
            $('#tt2').datagrid('reload');
            $.messager.alert('提示', '操作成功！');
        }

        function install(key) {
            Xiaov.SmartWeb.Application.SysAdmin.Admin_Plugins.Install(key, callback);
        }
        function uninstall(key) {
            Xiaov.SmartWeb.Application.SysAdmin.Admin_Plugins.UnInstall(key, callback);
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div class="easyui-tabs">
		<div title="插件安装包" style="padding:10px">
			 <table id="tt" class="easyui-datagrid" 
			data-options="singleSelect:true,collapsible:false,url:'Json/Plugin.aspx',toolbar:toolbar,rownumbers:true,nowrap: true, remoteSort: false">
		<thead>
			<tr>
				<th data-options="field:'Name',width:250,sortable: true">插件名称</th>
				<th data-options="field:'CreateTime',width:180,sortable: true">时间</th>   
                <th data-options="field:'FilePath',width:180,sortable: true">插件路径</th>             
			</tr>
		</thead>
	    </table>			
		</div>
		<div title="已装插件列表" style="padding:10px">				
			<table id="tt2" class="easyui-datagrid" 
			data-options="singleSelect:true,collapsible:false,url:'Json/PluginHasInstalled.aspx',toolbar:toolbar2,rownumbers:true,nowrap: true, remoteSort: false">
		    <thead>
			    <tr>
                    <th data-options="field:'PLUGINID',width:250,sortable: true">ID</th>
                    <th data-options="field:'PLUGINDLL',width:250,sortable: true">程序集</th>       
				    <th data-options="field:'PLUGINNAME',width:180,sortable: true, formatter: function (val, rec) { return unescape(val)}">插件名称</th>
                    <th data-options="field:'PLUGINSTATE',width:60,sortable: true, formatter: function (val, rec) {if(val=='1') return '<img src=/Resources/easyui-1.32/themes/icons/ok.png/>'; else return '<img src=/Resources/easyui-1.32/themes/icons/cancel.png/>'; }">状态</th> 				    
                    <th data-options="field:'PLUGINAUTHOR',width:100,sortable: true">作者</th>
                    <th data-options="field:'PLUGINVERSION',width:100,sortable: true">版本</th> 
			    </tr>
		    </thead>
                </table>
		</div>
        </div>
</asp:Content>
